#! /usr/bin/env python
# -*- coding:utf-8 -*-
# Author Jmz
# 对象是由类调用产生的，对象被当成方法调用，会触发类的__call__方法
# 类是由元类调用产生的，那么类被当成方法调用也应该触发元类的__call__方法


class teacher(object):
    __addr ="上海校区"
    def __init__(self,name):
        self.name = name
    def select_class(self):
        pass
    def __call__(self, *args, **kwargs):
        print("对象调用触发")
        print(args)
        print(kwargs)


egon = teacher('egon')
egon(23,"男",school = "oldboy")
# 对象调用触发
# (23, '男')
# {'school': 'oldboy'}


class Mymeta(type):
    def __call__(self, *args, **kwargs):
        print("我是元类的__call__ 方法，类被调用时触发")
        print(args)
        print(kwargs)


class Student(object,metaclass=Mymeta):   # Student = type("Student",(object,),{})
    pass


Student('jmz',18,school="交大")
# 我是元类的__call__ 方法，类被调用时触发
# ('jmz', 18)
# {'school': '交大'}













